<?php
// +----------------------------------------------------------------------
// | OneKeyAdmin [ Believe that you can do better ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2023 http://onekeyadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: MUKE <513038996@qq.com>
// +----------------------------------------------------------------------
namespace plugins\aliyunoss\admin\controller;

use think\facade\View;
use app\admin\BaseController;
use app\admin\model\Config as ConfigModel;
/**
 * 阿里云oss存储配置
 */
class Config extends BaseController
{
	public function index()
	{
		if ($this->request->isPost()) {
			$input = input('post.');
			ConfigModel::setVal('app_aliyunoss','阿里云OSS', $input['config']);
			return json(['status' => 'success', 'message' => '修改成功']);
		} else {
	        $config = ConfigModel::getVal('app_aliyunoss');
	        $config = $config ? $config : [
	            'accessKeyId'     => '', 
	            'accessKeySecret' => '', 
	            'endpoint'        => '', 
	            'bucket'          => '', 
	            'open'            => '0'
	        ];
	        View::assign('config', $config);
	        return View::fetch();
		}
	}
}